﻿using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using SmartCity.Shared;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;

namespace CommonManagement
{
    /// <summary>
    /// 字典控制器
    /// </summary>
    [RemoteService]
    [Area("commonManagement")]
    [Route("api/commonManagement/dict")]
    public class DictController : AbpController
    {
        // 获取
        [HttpGet]
        [Route("{dictType}")]
        public ResultResponse<List<DictPair>> GetAsync(string dictType)
        {
            switch (dictType)
            {
                case "adv_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(advTypeDict));
                case "balance_log_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(balanceLogTypeDict));
                case "order_status":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(orderStatusDict));
                case "cancel_status":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(cancelStatusDict));
                case "car_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(carTypeDict));
                case "film_category":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(filmCategoryDict));
                case "function_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(functionTypeDict));
                case "hospital_category_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(hospitalCategoryTypeDict));
                case "house_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(houseTypeDict));
                case "illegal_status":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(illegalStatusDict));
                case "license_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(licenseTypeDict));
                case "license_verify":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(licenseVerifyDict));
                case "live_operator_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(liveOperatorTypeDict));
                case "park_score_event":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(parkScoreEventDict));
                case "payment_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(paymentTypeDict));
                case "pay_status":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(payStatusDict));
                case "plate_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(plateTypeDict));
                case "play_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(playTypeDict));
                case "score_change_type":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(scoreChangeTypeDict));
                case "sys_user_sex":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(sysUserSexDict));
                case "sys_yes_no":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(sysYesNoDict));
                case "ticket_status":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(ticketStatusDict));
                case "times_seat_status":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(timesSeatStatusDict));
                case "times_status":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(timesStatusDict));
                case "tk_order_status":
                    return ResultResponse<List<DictPair>>.Successful(DictToArray(tkOrderStatusDict));
                default:
                    return ResultResponse<List<DictPair>>.Successful(new List<DictPair>());
            }
        }

        private readonly static Dictionary<string, string> advTypeDict = new Dictionary<string, string>()
        {
            { "主页轮播", "2" },
            { "引导页轮播", "1" }
        };
        private readonly static Dictionary<string, string> balanceLogTypeDict = new Dictionary<string, string>()
        {
            { "收入", "收入" },
            { "支出", "支出" }
        };
        private readonly static Dictionary<string, string> orderStatusDict = new Dictionary<string, string>()
        {
            { "未支付", "0" },
            { "已支付", "1" }
        };
        private readonly static Dictionary<string, string> cancelStatusDict = new Dictionary<string, string>()
        {
            { "驳回", "驳回" },
            { "通过", "通过" },
            { "申请中", "申请中" }
        };
        private readonly static Dictionary<string, string> carTypeDict = new Dictionary<string, string>()
        {
            { "新能源车", "新能源车" },
            { "汽油车", "汽油车" }
        };
        private readonly static Dictionary<string, string> filmCategoryDict = new Dictionary<string, string>()
        {
            { "喜剧", "4" },
            { "科幻", "8" },
            { "动作", "3" },
            { "战争", "7" },
            { "爱情", "2" },
            { "惊悚", "6" },
            { "故事", "1" },
            { "恐怖", "5" }
        };
        private readonly static Dictionary<string, string> functionTypeDict = new Dictionary<string, string>()
        {
            { "生活服务", "生活服务" },
            { "车主服务", "车主服务" },
            { "便民服务", "便民服务" }
        };
        private readonly static Dictionary<string, string> hospitalCategoryTypeDict = new Dictionary<string, string>()
        {
            { "普通诊", "2" },
            { "专家诊", "1" }
        };
        private readonly static Dictionary<string, string> houseTypeDict = new Dictionary<string, string>()
        {
            { "二手", "二手" },
            { "中介", "中介" },
            { "楼盘", "楼盘" },
            { "租房", "租房" }
        };
        private readonly static Dictionary<string, string> illegalStatusDict = new Dictionary<string, string>()
        {
            { "已缴款", "已缴款" },
            { "已处理未缴款", "已处理未缴款" },
            { "未处理", "未处理" },
            { "撤销申请中", "撤销申请中" },
            { "已撤销", "已撤销" }
        };
        private readonly static Dictionary<string, string> licenseTypeDict = new Dictionary<string, string>()
        {
            { "B1", "B1" },
            { "C3", "C3" },
            { "A3", "A3" },
            { "C2", "C2" },
            { "E", "E" },
            { "A2", "A2" },
            { "C1", "C1" },
            { "D", "D" },
            { "A1", "A1" },
            { "B2", "B2" },
            { "C4", "C4" }
        };
        private readonly static Dictionary<string, string> licenseVerifyDict = new Dictionary<string, string>()
        {
            { "6年", "6年" },
            { "长期", "长期" },
            { "10年", "10年" }
        };
        private readonly static Dictionary<string, string> liveOperatorTypeDict = new Dictionary<string, string>()
        {
            { "中国电信", "中国电信" },
            { "中国联通", "中国联通" },
            { "中国移动", "中国移动" }
        };
        private readonly static Dictionary<string, string> parkScoreEventDict = new Dictionary<string, string>()
        {
            { "兑换商品", "兑换商品" },
            { "充值", "充值" },
            { "绑定车辆", "绑定车辆" }
        };
        private readonly static Dictionary<string, string> paymentTypeDict = new Dictionary<string, string>()
        {
            { "电子支付", "电子支付" },
            { "微信", "微信" },
            { "支付宝", "支付宝" }
        };
        private readonly static Dictionary<string, string> payStatusDict = new Dictionary<string, string>()
        {
            { "已支付", "1" },
            { "未支付", "0" }
        };
        private readonly static Dictionary<string, string> plateTypeDict = new Dictionary<string, string>()
        {
            { "小型汽车", "小型汽车" },
            { "大型新能源汽车", "大型新能源汽车" },
            { "大型汽车", "大型汽车" },
            { "小型新能源汽车", "小型新能源汽车" },
            { "领馆汽车", "领馆汽车" },
            { "警用汽车", "警用汽车" }
        };
        private readonly static Dictionary<string, string> playTypeDict = new Dictionary<string, string>()
        {
            { "4DX", "4" },
            { "IMAX", "3" },
            { "3D", "2" },
            { "2D", "1" }
        };
        private readonly static Dictionary<string, string> scoreChangeTypeDict = new Dictionary<string, string>()
        {
            { "扣除", "扣除" },
            { "获取", "获取" }
        };
        private readonly static Dictionary<string, string> sysUserSexDict = new Dictionary<string, string>()
        {
            { "男", "0" },
            { "女", "1" }
        };
        private readonly static Dictionary<string, string> sysYesNoDict = new Dictionary<string, string>()
        {
            { "否", "N" },
            { "是", "Y" }
        };
        private readonly static Dictionary<string, string> ticketStatusDict = new Dictionary<string, string>()
        {
            { "过期", "0" },
            { "有效", "1" },
            { "已核销", "2" }
        };
        private readonly static Dictionary<string, string> timesSeatStatusDict = new Dictionary<string, string>()
        {
            { "已售", "1" },
            { "禁售", "2" },
            { "空闲", "0" }
        };
        private readonly static Dictionary<string, string> timesStatusDict = new Dictionary<string, string>()
        {
            { "停售", "0" },
            { "销售中", "1" },
            { "预售", "2" }
        };
        private readonly static Dictionary<string, string> tkOrderStatusDict = new Dictionary<string, string>()
        {
            { "待支付", "待支付" },
            { "退款", "退款" },
            { "待评价", "待评价" },
            { "完成", "完成" }
        };

        /// <summary>
        /// 字典转数组
        /// </summary>
        /// <param name="dict"></param>
        /// <returns></returns>
        private List<DictPair> DictToArray(Dictionary<string, string> dict)
        {
            var list = new List<DictPair>(dict.Count);
            foreach (var pair in dict)
            {
                list.Add(new DictPair()
                {
                    DictLabel = pair.Key,
                    DictValue = pair.Value
                });
            }
            return list;
        }
    }

    /// <summary>
    /// 字典对
    /// </summary>
    public class DictPair
    {
        public string DictLabel { get; set; }

        public string DictValue { get; set; }
    }
}